package com.share.rule.controller;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.core.web.page.TableDataInfo;
import com.share.rule.domain.FeeRule;
import com.share.rule.service.IFeeRuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/10/14 上午9:22
 */

@Tag(name = "费用规则接口管理")
@RestController
@RequestMapping("/feeRule")
@RequiredArgsConstructor
public class FeeRuleController  extends BaseController {

    private final IFeeRuleService feeRuleService;

    /**
     * 查询费用规则列表
     * @param feeRule
     * @return
     */
    @Operation(summary = "查询费用规则列表")
    @GetMapping("/list")
    public TableDataInfo list(FeeRule feeRule){
        return getDataTable(feeRuleService.selectFeeRuleList(feeRule));
    }

    /**
     * 获取费用规则详情
     * @param id
     * @return
     */
    @Operation(summary = "获取费用规则详情")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id){
        return success(feeRuleService.getById(id));
    }

    /**
     * 添加费用规则
     * @param feeRule
     * @return
     */
    @Operation(summary = "添加费用规则")
    @PostMapping()
    public AjaxResult add(@RequestBody FeeRule feeRule){
        return toAjax(feeRuleService.saveFeeRule(feeRule));
    }

    /**
     * 修改费用规则
     * @param feeRule
     * @return
     */
    @Operation(summary = "修改费用规则")
    @PutMapping()
    public AjaxResult update(@RequestBody FeeRule feeRule){
        return toAjax(feeRuleService.updateFeeRule(feeRule));
    }

    /**
     * 删除费用规则
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除费用规则")
    public AjaxResult remove(@PathVariable List<Long> ids){
        return toAjax(feeRuleService.removeByIds(ids));
    }

    @Operation(summary = "获取全部费用规则")
    @GetMapping("/getALLFeeRuleList")
    public AjaxResult getALLFeeRuleList(){
        return success(feeRuleService.selectAllRuleFeeList());
    }

}
